﻿@model DateTime?
@{
    string format = Model == null ? "" : String.Format("{0:dd/MM/yyyy}", Model.Value.ToString("dd/MM/yyyy"));

    string btnClass = "calendar";

    ViewData["class"] += " form-control";

    /* disabled keyboard */
    ViewData["onclick"] = " $(this).keydown(false)";

    if (ViewData["type"] == "dateTimePicker")
    {
        format = Model == null ? "" : String.Format("{0:dd/MM/yyyy HH:mm}", Model.Value.ToString("dd/MM/yyyy HH:mm"));
        ViewData["class"] += " dateTimePicker";
        ViewData["placeholder"] = "99/99/9999";
    }
    else if (ViewData["type"] == "timePicker")
    {
        format = Model == null ? "" : String.Format("{0:HH:mm}", Model.Value.ToString("HH:mm"));
        ViewData["class"] += " timePicker";
        ViewData["placeholder"] = "00:00";
    }

    if (Model.HasValue && Model.Value.Equals(DateTime.MinValue))
    {
        format = null;
    }

    if ((string)ViewData["disabledClass"] == "true")
    {
        ViewData["class"] += " disabledDate";
    }
}

 @{
     ViewData["type"] = "text";
     var inTable = ViewData["table"] != null;
     var clearClass = inTable ? "clearFieldTable" : "clearField";
     var positionClass = inTable ? "groupPositionTime" : string.Empty;
}

<div class="dateTimeGroup @positionClass">
    @Html.TextBox(string.Empty, format, ViewData)
    <span class="glyphicon glyphicon-remove-circle @clearClass"></span>
</div>






